package com.project.finance.mobile.user.service.impl;

import com.project.finance.common.mapper.TbUsersMapper;
import com.project.finance.common.po.TbUsers;
import com.project.finance.mobile.user.service.PersonalInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @Author: Brendan Li
 * @description 个人信息业务逻辑实现
 * @Date: 2019/12/09/20:21
 */
@Service
public class PersonalInfoServiceImpl implements PersonalInfoService {

    @Autowired
    private TbUsersMapper tbUsersMapper;

    @Override
    public int updateUser(TbUsers tbUsers) {
        Example example = new Example(TbUsers.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId",tbUsers.getUserId());
        int i = tbUsersMapper.updateByExampleSelective(tbUsers, example);
        return i;
    }

    @Override
    public int updateUserImg(int userId, String iconImg) {
        TbUsers tbUsers = new TbUsers();
        tbUsers.setIconImg(iconImg);
        Example example = new Example(TbUsers.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId",userId);
        int i = tbUsersMapper.updateByExampleSelective(tbUsers, example);
        return i;
    }
}
